package com.lu.service.dormitory;

import com.lu.entity.Dormitory;
import com.lu.mapper.DormitoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DormitoryService implements DormitoryServices{
    @Autowired
    private DormitoryMapper dormitoryMapper;
    //查询所有宿舍信息
    @Override
    public List<Dormitory> getDormitory() {
        return dormitoryMapper.findAllDormitory();
    }

    //插入宿舍数据
    @Override
    public void addDormitory(Dormitory dormitory) {
        dormitoryMapper.insertDormitoryData(dormitory);
    }

    //根据id查询宿舍数据
    @Override
    public List<Dormitory> findDormitoryById(Integer id) {
        return dormitoryMapper.findDormitoryById(id);
    }

    //修改宿舍数据
    @Override
    public void updateDormitory(Dormitory dormitory) {
        dormitoryMapper.updateDormitoryData(dormitory);
    }

    //根据id删除宿舍数据
    @Override
    public void deleteDormitory(Integer id) {
        dormitoryMapper.deleteDormitoryById(id);
    }

    //根据传入的寝室号和宿舍楼查询对应的数据
    @Override
    public List<Dormitory> findDormitoryByName(Dormitory dormitory) {
        return dormitoryMapper.findByNumBud(dormitory);
    }
}
